Martinig, A. R., S. L. P. Burk, Y. Yang, M. Lagisz, and S. Nakagawa
Published
October 17, 2024
Things to do for April
Rerun all the models
Put figures at the end
Add some text so the reader can understand
Go through code and add more annotations
Ask questions about things you do not understand
1 Setting up
1.1 Load packages
Code
pacman::p_load(tidyverse, # tidy family and related pacakges below kableExtra, # nice tables MuMIn, # multi-model inference emmeans, # post-hoc tests gridExtra, # may not use this pander, # nice tables metafor, # package for meta-analysis ape, # phylogenetic analysis MuMIn, # multi-model inference patchwork, # putting ggplots together - you need to install via devtool here, # making reading files easy orchaRd, # plotting orchard plots matrixcalc # matrix calculations# more too add)eval(metafor:::.MuMIn)
Table S1. Mean estimate with their 95% confidence intervals (lower and upper CI) and 95% prediction intervals (lower and upper PR) are presented along with p-value (pval) for intercept meta-analytic model with all five random effects.
Table S2. Mean estimate with their 95% confidence intervals (lower and upper CI) and 95% prediction intervals (lower and upper PR) are presented along with p-value (pval) for reduced intercept meta-analytic model without phylogeny as a random effect.
orchard_plot(mod_class, mod ="species_class", xlab ="Effect Size: Zr", group ="paperID", branch.size =4, angle =45)
Figure S2. Mean fitness effect of different taxonomic classes. We present mean effect sizes (Zr) along with 95% confidence (thicker bar) and prediction (thinner bars) intervals are depicted along with individual data points (blue circles) scaled by precision (1/SE).
Code
tab_class <-all_models(mod_class, mod ="species_class", type ="normal")# saving tab_class as RDSsaveRDS(tab_class, here("Rdata", "tab_class.RDS"))
Table S3. Mean estimates of different taxonomic classes with their 95% confidence intervals (lower and upper CI) and 95% prediction intervals (lower and upper PR) are presented along with p-value (pval).
orchard_plot(mod_type, mod ="study_type", xlab ="Effect Size: Zr", group ="paperID", branch.size =4)
Figure S3. Mean fitness effect of natural and semi-natural study types. We present mean effect sizes (Zr) along with 95% confidence (thicker bar) and prediction (thinner bars) intervals are depicted along with individual data points (blue circles) scaled by precision (1/SE).
Code
tab_type <-all_models(mod_type, mod ="study_type", type ="normal")# saving tab_type as RDSsaveRDS(tab_type, here("Rdata", "tab_type.RDS"))
Table S4. Mean estimates of natural and semi-natural study types with their 95% confidence intervals (lower and upper CI) and 95% prediction intervals (lower and upper PR) are presented along with p-value (pval).
orchard_plot(mod_design, mod ="study_design", xlab ="Effect Size: Zr", group ="paperID", branch.size =4, angle =45)
Figure S4. Mean fitness effect of gradient and contrast study designs. We present mean effect sizes (Zr) along with 95% confidence (thicker bar) and prediction (thinner bars) intervals are depicted along with individual data points (blue circles) scaled by precision (1/SE).
Code
tab_design <-all_models(mod_design, mod ="study_design", type ="normal")# saving tab_design as RDSsaveRDS(tab_design, here("Rdata", "tab_design.RDS"))
Table S5. Mean estimates of gradient and contrast study designs with their 95% confidence intervals (lower and upper CI) and 95% prediction intervals (lower and upper PR) are presented along with p-value (pval).
orchard_plot(mod_disp, mod ="dispersal_type", xlab ="Effect Size: Zr", group ="paperID", branch.size =4, angle =45)
Figure S5. Mean fitness effect of natal and breeding dispersal. We present mean effect sizes (Zr) along with 95% confidence (thicker bar) and prediction (thinner bars) intervals are depicted along with individual data points (blue circles) scaled by precision (1/SE).
Code
tab_disp <-all_models(mod_disp, mod ="dispersal_type", type ="normal")# saving tab_disp as RDSsaveRDS(tab_disp, here("Rdata", "tab_disp.RDS"))
Table S6. Mean estimates of natal and breeding dispersal with their 95% confidence intervals (lower and upper CI) and 95% prediction intervals (lower and upper PR) are presented along with p-value (pval).
orchard_plot(mod_phase, mod ="dispersal_phase", xlab ="Effect Size: Zr", group ="paperID", branch.size =4, angle =45)
Figure S6. Mean fitness effect of prospection and settlement dispersal phases. We present mean effect sizes (Zr) along with 95% confidence (thicker bar) and prediction (thinner bars) intervals are depicted along with individual data points (blue circles) scaled by precision (1/SE).
Code
tab_phase <-all_models(mod_phase, mod ="dispersal_phase", type ="normal")# saving tab_phase as RDSsaveRDS(tab_phase, here("Rdata", "tab_phase.RDS"))
Table S7. Mean estimates of prospection and settlement dispersal phases with their 95% confidence intervals (lower and upper CI) and 95% prediction intervals (lower and upper PR) are presented along with p-value (pval).
orchard_plot(mod_sex, mod ="sex", xlab ="Effect Size: Zr", group ="paperID", branch.size =4)
Figure S7. Mean fitness effect of females, males, or both sexes grouped. We present mean effect sizes (Zr) along with 95% confidence (thicker bar) and prediction (thinner bars) intervals are depicted along with individual data points (blue circles) scaled by precision (1/SE).
Code
tab_sex <-all_models(mod_sex, mod ="sex", type ="normal")# saving tab_sex as RDSsaveRDS(tab_sex, here("Rdata", "tab_sex.RDS"))
Table S8. Mean estimates of females, males, or both sexes grouped with their 95% confidence intervals (lower and upper CI) and 95% prediction intervals (lower and upper PR) are presented along with p-value (pval).
orchard_plot(mod_age1, mod ="age_class_clean", xlab ="Effect Size: Zr", group ="paperID", branch.size =4)
Figure S8. Mean fitness effect of life history stage (adult, juvenile, or mixed). We present mean effect sizes (Zr) along with 95% confidence (thicker bar) and prediction (thinner bars) intervals are depicted along with individual data points (blue circles) scaled by precision (1/SE).
Code
tab_age1 <-all_models(mod_age1, mod ="age_class_clean", type ="normal")# saving tab_age1 as RDSsaveRDS(tab_age1, here("Rdata", "tab_age1.RDS"))
Table S9. Mean estimates of life history stage (adult, juvenile, or mixed) with their 95% confidence intervals (lower and upper CI) and 95% prediction intervals (lower and upper PR) are presented along with p-value (pval).
orchard_plot(mod_age2, mod ="age_class", xlab ="Effect Size: Zr", group ="paperID", branch.size =4)
Figure S9. Mean fitness effect of life history stage at the level of precision reported (A: adult, Y: yearling, J: juvenile). We present mean effect sizes (Zr) along with 95% confidence (thicker bar) and prediction (thinner bars) intervals are depicted along with individual data points (blue circles) scaled by precision (1/SE).
Code
# table not created for this (not meaningful for some levels)
3.3 Higher level
Code
mod_fit1 <-rma.mv(yi = yi, V = VCV,mod =~ fitness_higher_level -1,data = dat, random =list(~1| effectID,~1| paperID,~1| species_cleaned),test ="t",sparse =TRUE)summary(mod_fit1)
orchard_plot(mod_fit1, mod ="fitness_higher_level", xlab ="Effect Size: Zr", group ="paperID", branch.size =4, angle =45)
Figure S10. Mean fitness effect of different fitness components (survival, reproduction, and indirect fitness). We present mean effect sizes (Zr) along with 95% confidence (thicker bar) and prediction (thinner bars) intervals are depicted along with individual data points (blue circles) scaled by precision (1/SE).
Code
tab_fit1 <-all_models(mod_fit1, mod ="fitness_higher_level", type ="normal")# saving tab_fit1 as RDSsaveRDS(tab_fit1, here("Rdata", "tab_fit1.RDS"))
Table S10. Mean estimates of different fitness components (survival, reproduction, and indirect fitness) with their 95% confidence intervals (lower and upper CI) and 95% prediction intervals (lower and upper PR) are presented along with p-value (pval).
orchard_plot(mod_fit2, mod ="fitness_metric_clean", xlab ="Effect Size: Zr", group ="paperID", branch.size =4, angle =45)
Figure S11. Mean fitness effect of different fitness components at a finer resolution. We present mean effect sizes (Zr) along with 95% confidence (thicker bar) and prediction (thinner bars) intervals are depicted along with individual data points (blue circles) scaled by precision (1/SE).
Code
# table not created for this (not meaningful for some levels)
Code
mod_gen <-rma.mv(yi = yi, V = VCV,mod =~ whose_fitness -1,data = dat, random =list(~1| effectID,~1| paperID,~1| species_cleaned),test ="t",sparse =TRUE)summary(mod_gen)
orchard_plot(mod_gen, mod ="whose_fitness", xlab ="Effect Size: Zr", group ="paperID", branch.size =4)
Figure S12. Mean fitness effect of non-dispersers and dispersers and their descendants. We present mean effect sizes (Zr) along with 95% confidence (thicker bar) and prediction (thinner bars) intervals are depicted along with individual data points (blue circles) scaled by precision (1/SE).
Code
tab_gen <-all_models(mod_gen, mod ="whose_fitness", type ="normal")# saving tab_gen as RDSsaveRDS(tab_gen, here("Rdata", "tab_gen.RDS"))
Table S11. Mean estimates of non-dispersers and dispersers and their descendants with their 95% confidence intervals (lower and upper CI) and 95% prediction intervals (lower and upper PR) are presented along with p-value (pval).
# getting absolute values for effect sizes as we expect shorter years will have more fluctuationsdat$ln_study_duration <-log(dat$study_duration+1)mod_dur <-rma.mv(yi = yi, V = VCV,mod =~ ln_study_duration,data = dat, random =list(~1| effectID,~1| paperID,~1| species_cleaned),test ="t",sparse =TRUE)summary(mod_dur)
orchard_plot(mod_focus, mod ="fitness_main_focus", xlab ="Effect Size: Zr", group ="paperID", branch.size =4, angle =90)
Figure S17. Add text.
Code
tab_focus <-all_models(mod_focus, mod ="fitness_main_focus", type ="normal")# saving tab_focus as RDSsaveRDS(tab_focus, here("Rdata", "tab_focus.RDS"))
orchard_plot(mod_confirm, mod ="confirmation_bias", xlab ="Effect Size: Zr", group ="paperID", branch.size =4, angle =90)
Figure S20. Add text.
Code
tab_confirm <-all_models(mod_confirm, mod ="confirmation_bias", type ="normal")# saving tab_confirm as RDSsaveRDS(tab_confirm, here("Rdata", "tab_confirm.RDS"))
# the interaction between 2 categorical variables are the same as creating a new variable with 2 categories combined so we use that approach dat$sex_species_class <-as.factor(paste(dat$sex, dat$species_class ,sep ="_"))mod_sex_species_class <-rma.mv(yi = yi, V = VCV,mod =~ sex_species_class -1,data = dat, random =list(~1| effectID,~1| paperID,~1| species_cleaned),test ="t",sparse =TRUE)summary(mod_sex_species_class)
orchard_plot(mod_sex_species_class, mod ="sex_species_class", xlab ="Effect Size: Zr", group ="paperID", branch.size =4, angle =45)
Figure S23. Add text.
Code
tab_sex_species_class <-all_models(mod_sex_species_class, mod ="sex_species_class", type ="normal")# saving tab_sex_species_class as RDSsaveRDS(tab_sex_species_class, here("Rdata", "tab_sex_species_class.RDS"))
orchard_plot(mod_sex_whose_fitness, mod ="sex_whose_fitness", xlab ="Effect Size: Zr", group ="paperID", branch.size =4, angle =45)
Figure S23. Add text.
Code
tab_sex_whose_fitness <-all_models(mod_sex_whose_fitness, mod ="sex_whose_fitness", type ="normal")# saving tab_sex_whose_fitness as RDSsaveRDS(tab_sex_whose_fitness, here("Rdata", "tab_sex_whose_fitness.RDS"))
orchard_plot(mod_sex_fitness, mod ="sex_fitness_higher_level", xlab ="Effect Size: Zr", group ="paperID", branch.size =4, angle =45)
Figure S24. Add text.
Code
tab_sex_fitness <-all_models(mod_sex_fitness, mod ="sex_fitness_higher_level", type ="normal")# saving tab_sex_fitness as RDSsaveRDS(tab_sex_fitness, here("Rdata", "tab_sex_fitness.RDS"))
orchard_plot(mod_sex_dispersal_type, mod ="sex_dispersal_type", xlab ="Effect Size: Zr", group ="paperID", branch.size =4, trunk.size =0.5, angle =45)
Figure S25. Add text.
Code
tab_sex_dispersal_type <-all_models(mod_sex_dispersal_type, mod ="sex_dispersal_type", type ="normal")# saving tab_sex_dispersal_type as RDSsaveRDS(tab_sex_dispersal_type, here("Rdata", "tab_sex_dispersal_type.RDS"))
# relative importance of each predictor for all the modelsimportance <-sw(candidates)importance
age_class_clean dispersal_phase whose_fitness
Sum of weights: 0.74 0.40 0.40
N containing models: 32 32 32
fitness_higher_level sex dispersal_type
Sum of weights: 0.28 0.20 0.14
N containing models: 32 32 32
# if each group n is available - assume n/2dat$effectN <-ifelse(is.na(dat$n_group_1), (dat$n/2)*2/dat$n, (dat$n_group_1 * dat$n_group_2) / (dat$n_group_1 + dat$n_group_2))dat$sqeffectN <-sqrt(dat$effectN)mod_egger <-rma.mv(yi = yi, V = VCV,mod =~ sqeffectN,data = dat, random =list(~1| effectID,~1| paperID,~1| species_cleaned),test ="t",sparse =TRUE)summary(mod_egger)